package com.yang.Offer;

/**
 * @Author: yang
 * @Description:  输入一棵二叉搜索树，将该二叉搜索树转换成一个排序的循环双向链表。
 *                要求不能创建任何新的节点，只能调整树中节点指针的指向。
 * @Date: Created in 12:40 2022/8/2
 * @Modified By:
 */
public class Offer36 {
}


/*
// Definition for a Node.
class Node {
    public int val;
    public Node left;
    public Node right;

    public Node() {}

    public Node(int _val) {
        val = _val;
    }

    public Node(int _val,Node _left,Node _right) {
        val = _val;
        left = _left;
        right = _right;
    }
};
*/
class Offer36Solution {
/*    Node pre, head;
    public Node treeToDoublyList(Node root) {
        if(root == null){
            return null;
        }
        dfs(root);
        // 此时pre指向链表结尾
        head.left = pre;
        pre.right = head;

        return head;
    }
    private void dfs (Node cur){
        if( cur == null){
            return;
        }
        dfs(cur.left);
        if(pre != null){
            pre.right = cur;
        }else{
            head = cur;
        }
        // 改变当前节点左指向为pre
        // 而pre 变成cur(下一个节点的)
        cur.left = pre;
        pre = cur;
        dfs(cur.right);
    }*/
}
